<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Models\Candy\Content;

class CreateCandyContentTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $sql = "CREATE TABLE `".Content::getFullTableTable()."` (
  `".Content::DB_FIELD_ID."` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `".Content::DB_FIELD_DATE_ID."` int(11) NOT NULL COMMENT '日期id',
  `".Content::DB_FIELD_TITLE."` varchar(255) DEFAULT NULL COMMENT '标题',
  `".Content::DB_FIELD_DESCRIPTION."` text COMMENT '描述',
  `".Content::DB_FIELD_FILE_TYPE."` tinyint(3) NOT NULL DEFAULT '1' COMMENT '类型1图片2视频',
  `".Content::DB_FIELD_FILE_SOURCE."` tinyint(4) NOT NULL DEFAULT '1' COMMENT '来源1阿里云2url',
  `".Content::DB_FIELD_FILE_VALUE."` varchar(255) NOT NULL DEFAULT '' COMMENT '文件路径',
  `".Content::DB_FIELD_SORT."` int(11) NOT NULL DEFAULT '0' COMMENT '排序',
  `".Content::DB_FIELD_IS_PRIVATE."` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '私密图片0不是1是',
  `".Content::DB_FIELD_CREATED_AT."` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `".Content::UPDATED_AT."` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `".Content::DB_FIELD_DELETED_AT."` timestamp NULL DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`),
  KEY `idx_date_id` (`date_id`),
  KEY `idx_is_private` (`is_private`),
  KEY `idx_sort` (`sort`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='糖果';";
        DB::connection()->getPdo()->exec($sql);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop(Content::getFullTableTable());
    }
}
